#include <bits/stdc++.h>
using namespace std;
struct car
{
    int d,v,a;
};
int T;
int n,m,L,V;
car c[100010];
int p[100010];
int p2[100010];
int ans2,ans;
int Find(int x,int f[],int len)
{
    int l=1,r=len;
    int best=-1;
    while (l<=r)
    {
        int mid=(l+r)/2;
        if (f[mid]>=x)
        {
            r=mid-1;
            best=f[mid];
        }
        else
        {
            l=mid+1;
        }
    }
    return best;
}
long long F(long long x)
{
    return x<0?1LL:(x==0?0LL:V*1LL+1);
}
void dfs(int dep,int len)
{
    if (dep==m+1)
    {
        int cnt=0;
        for (int i=1;i<=n;i++)
        {
            if (c[i].d>p2[len] || 1LL*F(1LL*F(p2[len]-c[i].d)*F(c[i].a))+c[i].v<=1LL*V && 1LL*F(1LL*F(F(Find(c[i].d,p2,len))-c[i].d)*F(c[i].a))+c[i].v<=1LL*V)
            {
                continue;
            }
            cnt++;
        }
        if (cnt==ans2)
        {
            ans=max(ans,m-len);
        }
        return ;
    }
    dfs(dep+1,len);
    p2[++len]=p[dep];
    dfs(dep+1,len);
    len--;
}
int main()
{
    //freopen("detect.in","r",stdin);
    //freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while (T--)
    {
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for (int i=1;i<=n;i++)
        {
            scanf("%d%d%d",&c[i].d,&c[i].v,&c[i].a);
        }
        for (int i=1;i<=m;i++)
        {
            scanf("%d",&p[i]);
        }
        ans2=0;
        for (int i=1;i<=n;i++)
        {
            if (c[i].d>p[m] || 1LL*F(1LL*F(p[m]-c[i].d)*F(c[i].a))+c[i].v<=1LL*V && 1LL*F(1LL*F(F(Find(c[i].d,p,m))-c[i].d)*c[i].a)+c[i].v<=1LL*V)
            {
                continue;
            }
            ans2++;
        }
        printf("%d ",ans2);
        ans=0;
        dfs(1,0);
        printf("%d\n",ans);
    }
    return 0;
}
